package com.aim.util.filters;

import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

/**
 * User: Avraham Shvartzon
 * Date: 6/17/14
 */
public class FilterUtil {

    public static <T> Filter<T> dummy(Class<T> clazz){
        return new Filter<T>() {
            @Override
            public boolean accept(T t) {
                return true;
            }
        };
    }

    public static <T> Collection<T> filterHits(Collection<T> collection, Filter<T> filter){
        List<T> filtered = new LinkedList<T>();
        for (T t : collection) {
            if (filter.accept(t)){
                filtered.add(t);
            }
        }
        return filtered;
    }


}
